# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

# 获取浏览器驱动
driver = webdriver.Firefox()
# 打开测试的网址
url = 'file:///C:/Users/tedu/Desktop/NSD2407/html/registerA.html'
driver.get(url)
# XPATH定位
# 定位用户名文本框
# /  绝对路径，必须一层一层的查找，不能跳跃
# // 相对路径，可以跳跃
# 下标从1开始
# username = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[1]/input')
# username = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[@id="p1"]/input')
username = driver.find_element(By.XPATH, '//p[@id="p1"]/input')
username.send_keys('hello')
# 定位密码框输入值
# password = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[2]/input')
# password = driver.find_element(By.XPATH, '//input[@id="passwordA"]')
# * 任意元素
password = driver.find_element(By.XPATH, '//*[@name="passwordA"]')
password.send_keys('123456')

tel = driver.find_element(By.XPATH, '//*[@id="telA"]')
tel.send_keys('18899998888')
# //*[@id="emailA"]
email = driver.find_element(By.XPATH, '//*[@name="emailA"]')
email.send_keys('123@qq.com')
sleep(3)
driver.find_element(By.XPATH, '//*[@value="注册A"]').click()

# 停顿3秒，关闭浏览器
sleep(3)
driver.quit()